package com.testing.hibernateapp.tapestry.pages;

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.testing.hibernateapp.beans.PersonBean;
import com.testing.hibernateapp.interfaces.Person;
import com.testing.hibernateapp.service.UniversalHibernateDAO;

public class AddPerson {
	
	@Property
	private Person person;
	
	@Inject
	private UniversalHibernateDAO<Person> hibernateDAO;
	
	void onActivate() {
		person = new PersonBean();
	}
	
	Object onSuccess() {
		hibernateDAO.setObjectClass(PersonBean.class);
		Person person2 = hibernateDAO.save(person);
		System.out.println(hibernateDAO.retrieve().size());
		
		return ViewPersons.class;
	}

}
